package com.pillpoppers.pillbox;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckedTextView;
import android.widget.TextView;

public class AlarmSettingAdapter extends BaseAdapter {
	
	private final String[] OPTIONS = {"Pill", "Active", "Time", "Repeat Day", "Alarm By"};

	public static final String[] ALARM_BY_OPTIONS = {"Vibrate", "Ring", "Silent"};
	public static final String[] DAY_OF_WEEK_OPTIONS = 
		{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
	
	private Schedule data;
	private LayoutInflater inflater;

	public AlarmSettingAdapter(Context context, Schedule data) {
		inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		this.data = data;
	}
	
	@Override
	public int getCount() {
		return OPTIONS.length;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = convertView;
		if (view == null) {
			if (position == 1)
				view = inflater.inflate(R.layout.simple_list_item_2_multiple_choice, null);
			else
				view = inflater.inflate(android.R.layout.simple_list_item_2, null);
		}

		TextView topTextView = (TextView) view.findViewById(android.R.id.text1);
		topTextView.setText(OPTIONS[position]);
		
		if (position == 1)
			((CheckedTextView) topTextView).setChecked(data.isActive());

		TextView bottomTextView = (TextView) view.findViewById(android.R.id.text2);
		bottomTextView.setText(data.getFormattedDataString(position));
			
		return view;
	}

}
